const db = require('../db/index')

exports.getCartInfo = (req, res) => {
    const sql = `SELECT * FROM cartitem order by id asc`
    
    // 从请求中提取 id 参数，可以是 req.params 或 req.query
    // console.log(req)
    // const cartItemId =  req.user.id
    // console.log("Requested Cart ID:", cartItemId);  // 输出 cartItemId
    db.query(sql, (err, results) => {
        if (err) return res.cc(err)
        
        if (results.length === 0) return res.cc('获取购物车信息失败')
        
        res.send({
            status: 0,
            message: '获取购物车信息成功',
            data: results
        })
    })
}
